/**
 * 附属设备页签的按钮处理
 */
 import ampub from 'ampub';
 import fa from 'fa';
 import constants from '../../constants/index';
 import { setBodyBtnsEnable } from './setStatus';
 
 
 const { utils } = ampub;
 const { showMessage } = utils.msgUtils;
 const { getMultiLangByID } = utils.multiLangUtils;
 const { fa_utils } = fa;
 const { metaUtil } = fa_utils;
 const steprentstandard_tab = constants.AREA.CARD.STEPRENTSTANDARD_TAB;
 
 export default function buttonClick(props, id) {
     const that = this;
     switch (id) {
         //增行
         case constants.CARD_BTNS.TABLE_HEAD.STEPRENTSTANDARD_TAB.ADD_LINE:
             doAddLine.call(that);
             break;
 
         //删行
         case constants.CARD_BTNS.TABLE_HEAD.STEPRENTSTANDARD_TAB.DELETE_LINE:
             doDeleteLine.call(that);
             break;
 
         //批改
         case constants.CARD_BTNS.TABLE_HEAD.STEPRENTSTANDARD_TAB.BATCH_ALTER:
             doBatchAlter.call(that);
             break;
 
         default:
             break;
     }
 }
 
 function doAddLine() {
     this.props.cardTable.addRow(steprentstandard_tab);
 }
 
 function doDeleteLine() {
     let rowsWillDel = this.props.cardTable.getCheckedRows(steprentstandard_tab);
     let indexs = rowsWillDel.map((row) => row.index);
     this.props.cardTable.delRowsByIndex(steprentstandard_tab, indexs);
     setBodyBtnsEnable(this.props, steprentstandard_tab);
 }
 
 function doBatchAlter() {
     const colAllowedAlter = metaUtil.getAreaItemFields(this.props, steprentstandard_tab);
     let index = colAllowedAlter.findIndex((e, i) => {
         return e === 'pk_subequip';
     });
     if (index > -1) {
         colAllowedAlter.splice(index, 1);
     }
 
     let changeData = this.props.cardTable.getTableItemData(steprentstandard_tab);
     const field = changeData.batchChangeKey;
     if (colAllowedAlter.includes(field)) {
         //1、调用平台方法进行批改
         const lastEditField = this.props.cardTable.batchChangeTableData(steprentstandard_tab);
     } else {
         /*国际化处理：该列不支持批改！*/
         showMessage(this.props, { content: getMultiLangByID('201201504A-000024'), color: 'info' });
     }
 }
 
